Repository navigation
Conversation
vigoo
left a comment
There was a problem hiding this comment.
Reviewed only this PR's delta against #231 (d3e9d83..dc2b680). One medium-severity public API defect and two optional convention notes follow. Verification used the actual Rust backend with zstd-safe 7.2.4 / libzstd 1.5.7 and the actual JS wrapper with Node stream/buffer adapters: 216 output/error comparisons against Node 26.13.1 matched, while separate byte-accounting probes reproduced the finding. This is not end-to-end WASI evidence; I did not rerun the full WASI/QuickJS suite locally. Exact-head CI was independently checked and is successful.
|
|
||
| _processChunk(chunk, flush, limit = _getKMaxLength()) { | ||
| const data = toUint8Array(toBuffer(chunk)); | ||
| this._bytesWritten += data.length; |
There was a problem hiding this comment.
Medium — DEFECT: bytesWritten includes ignored trailing junk.
This adds all supplied bytes, including input that the decoder discards after the compressed stream ends. _processStream repeats this at line 1266, and the native garbage branch also reports discarded bytes as consumed.
Reproducer: const frame = zlib.zstdCompressSync('hello'); const input = Buffer.concat([frame, Buffer.from('junk')]); const result = zlib.zstdDecompressSync(input, { info: true });
The frame is 14 bytes. Node 26.13.1 returns result.engine.bytesWritten === 14; this implementation returns 18. Both return hello. The same difference occurs through callback info: true and the stream API. Callers using this public property to locate the unconsumed suffix get the wrong boundary.
Please track codec-consumed bytes separately from bytes discarded to advance the input driver, preserving partial-prefix accounting, and add public regression cases for sync, callback, and streaming decompression with trailing junk. Simply summing the current native consumed return would still include the junk. Confidence: high; reproduced with the actual JS wrapper and Rust backend in the scoped native harness.
There was a problem hiding this comment.
Addressed in df468ecd. Both JS paths now add codec-consumed bytes to bytesWritten. The native trailing-junk branch returns consumed=0 and done=true, so the driver stops without counting discarded bytes. Buffered partial prefixes remain counted once. Public WASM regressions cover sync, callback and streaming decompression, including split junk, partial prefixes, concatenated and skippable frames, with pinned Node controls. The optional layout/visibility notes are unchanged.
| use flate2::{Compression, Decompress, FlushDecompress, Status}; | ||
|
|
||
| #[cfg(feature = "zstd")] | ||
| mod zstd; |
There was a problem hiding this comment.
Low, nonblocking — MAINTAINABILITY/CONVENTION (CS-004). Adding this child module introduces the mixed zlib.rs + zlib/zstd.rs layout. The review convention calls for a directory module with zlib/mod.rs when a module has children. Consider using that layout; this is an optional organization note, not a correctness issue.
| } | ||
|
|
||
| pub(super) fn new( | ||
| decompress: bool, |
There was a problem hiding this comment.
Low, nonblocking — MAINTAINABILITY/CONVENTION (CS-003). The new backend entry points use pub(super) (new, push, reset, and close). The review convention prefers private or pub instead of restricted visibility. Consider pub for these parent-called functions while keeping the backend module itself private. This is a convention note, not a functional defect.
vigoo
left a comment
There was a problem hiding this comment.
Re-reviewed the own delta against the refreshed #218 base. The bytesWritten finding is resolved, including trailing junk and split-prefix accounting. No new blocking findings; the earlier visibility and module-layout notes remain optional. Local source-harness checks and inspected exact-head CI support this assessment; the full WASI/QuickJS suite was not rerun locally.
node-26-targetat df908bf7, including main a57ed896 and folded Fix SQLite prepare and value contracts [skip ci] #231. Retargeted to main after Switch node_compat to Node 26.13.1 #218 landed at 2bc23cf9; main's tree equals the reviewed foundation, so the scoped diff and prospective merge tree are unchangedzstdthrough zstd-safe 7.2.4 / reference libzstd 1.5.7, as selected by Dávid; included in full tiers, excluded fromnormal-p3, native workers disabled for WASIchunkSizeand readable backpressure; convenience APIs enforce totalmaxOutputLength. Frame/reset semantics and explicit/finalizer ownership are preservedinfo, preserves native error codes under patched intrinsics, adds direct ZSTD aliases and checks callbacks before input conversionbytesWrittenfinding in df468ecd: accepted input is counted per native step, ignored junk counts zero, and already accepted partial prefixes count once. No ABI, frame/reset, error-policy or Reject trailing input across zlib codecs #239 branch changes; optional layout/visibility notes left unchanged18 !== 14) and green after the fix; identical Node26 controls pass. Accounting cases cover sync/callback/stream, split prefixes, concatenated/skippable frames and junk. No new test inventory or generated-output changeschanges_requiredreviews and circuit-breaker history are retainedadd-zstdpreserved until Reject trailing input across zlib codecs #239 is retargeted. No duplicate review request or source change. No full compatibility-discovery campaign, broader option/getter/private-API parity, Golem durability/recovery, shipped release-size/performance/heap or optional-full licensing qualification claimed; configured CI success does not finish GOL-1947Node compatibility
Compared with main at2bc23cf9 (base report identical to reviewed foundation df908bf/d3e9d832): primary 3200/4499 (71.1%) → 3228/4523 (71.4%); full public 3200/9654 (33.1%) → 3228/9654 (33.4%). Total 10794 unchanged. The repair promotes only the explicitly evaluated
test-zlib-decode-strings.jscase, after it passed with pristine Node26 assertions. The foundation update/retarget itself changes none of these counts.Only 28 completely passing cases become runnable: ten prior gaps and 18 newly evaluated cases. Another six newly evaluated failures become known gaps; the primary denominator therefore increases by 24, not by excluding failures. zlib runnable 45 → 73, gaps 15 → 11, unevaluated 260 → 236, total 324 unchanged.
Matched debug component builds at initial source 6b5b62e4 differ only by the zstd feature: 31,434,664 vs 28,210,270 bytes (3,224,394 added bytes); re-enabling reproduced identical enabled bytes. Not repeated after the frame-accounting or current corrective repairs; this is historical evidence, not a release-size or memory measurement.